package cn.dada.dadarecipes.community.audit.controller;

import cn.dada.dadarecipes.base.response.JsonResult;
import cn.dada.dadarecipes.community.audit.pojo.dto.AuditParam;
import cn.dada.dadarecipes.community.audit.pojo.dto.AuditQuery;
import cn.dada.dadarecipes.community.audit.pojo.vo.AuditVO;
import cn.dada.dadarecipes.community.audit.service.AuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "02.02文章审核管理")
@RestController
@RequestMapping("/v1/article/audit/")
public class AuditController {
    @Autowired
    private AuditService auditService;

    /**
     * 文章审核列表查询
     * @param auditQuery
     * @return
     */
    @GetMapping("select")
    @ApiOperation("文章审核列表查询")
    public JsonResult selectAudit(AuditQuery auditQuery) {
        log.debug("控制器-文章审核表查询:{}", auditQuery);
        List<AuditVO> list = auditService.selectAudit(auditQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("update")
    @ApiOperation("文章审核状态更新")
    public JsonResult updateAuditStatus(AuditParam auditParam) {
        log.debug("控制器-文章审核状态更新: {}",auditParam);
        auditService.updateAuditStatus(auditParam);
        return JsonResult.ok();
    }
}
